Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes iOS Debug packaged-bundle loading for brownfield apps running without Metro.
This PR addresses the case where a consumed brownfield XCFramework is built in
Debugand the host app wants to load the packaged JavaScript bundle instead of relying on a dev server.Root cause
There were two separate issues:
Debug, the iOS runtime always preferred Metro and ignored the embeddedmain.jsbundleDebug, the simulator slice of the packagedBrownfieldLib.xcframeworkdid not containmain.jsbundleWhat changed
Runtime
preferBundledBundleInDebugtoReactNativeBrownfieldpreferBundledBundleInDebug = true, Debug builds load the embedded bundlebundleURLOverridefallback behavior when the override returnsnilPackaging
main.jsbundlefrom the device framework build product into the simulator framework build productBrownfieldLib.xcframeworkso the simulator slice also containsmain.jsbundleValidation / coverage
iOS native testsCI job for Swift-based iOS testsRepro note
This issue only reproduces when the consumed XCFrameworks are themselves built in
Debug.A
Debughost app linked againstRelease-built XCFrameworks is a false negative, because the framework runtime has already been compiled without the Debug Metro branch.Validation
swift testinpackages/react-native-brownfield/iosyarn workspace @callstack/brownfield-cli test src/brownfield/utils/__tests__/copy-debug-bundle-to-simulator-slice.test.tsyarn exec brownfield package:ios --scheme BrownfieldLib --configuration DebugDebug-iphonesimulator/BrownfieldLib.framework/main.jsbundleexistsBrownfieldLib.xcframework/ios-arm64_x86_64-simulator/BrownfieldLib.framework/main.jsbundleexistsUser impact
Host apps can now explicitly opt into running a Debug-built brownfield framework from the packaged bundle:
With the normal Debug packaging flow, the packaged simulator XCFramework now includes the bundle needed for that opt-in to work without Metro.